import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home.vue'
import DataManage from '@/views/DataManage.vue'
import SystemSetting from '@/views/SystemSetting.vue'
import UserList from '@/views/UserList.vue'

const routes = [
  { 
    path: '/', 
    name: 'Home', 
    component: Home,
    meta: { title: '首页' }
  },
  { 
    path: '/data', 
    name: 'DataManage', 
    component: DataManage,
    meta: { title: '数据管理' }
  },
  { 
    path: '/setting', 
    name: 'SystemSetting', 
    component: SystemSetting,
    meta: { title: '系统设置' }
  },
  {
    path: '/users',
    name: 'UserList',
    component: UserList,
    meta: { title: '用户管理' }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '熊猫系统'
  next()
})

export default router